package com.ben.chatroom.common.util;

import lombok.extern.slf4j.Slf4j;

/**
 * @author huangyijun
 */
@Slf4j
public class ClassLoaderUtil {

  /**
   * 显示classLoaderTree
   * 当前加载器和所有父加载器
   */
  public static void showLoader4Class(Class clazz) {
    ClassLoader loader = clazz.getClassLoader();
    showLoaderTree(loader);
  }

  /**
   * 迭代，显示class loader和父加载器
   */
  public static void showLoaderTree(ClassLoader loader) {
    while(loader != null) {
      log.info(loader.toString());
      loader = loader.getParent();
    }
  }

}
